package com.usian.controller;

import com.usian.api.admin.ChannelControllerApi;
import com.usian.model.admin.dtos.ChannelDto;
import com.usian.model.admin.pojos.AdChannel;
import com.usian.model.common.dtos.ResponseResult;
import com.usian.service.AdChannelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/api/v1/channel")
@RestController
public class AdchannelController implements ChannelControllerApi {

    @Autowired
    private AdChannelService adChannelService;

    @PostMapping("/list")
    @Override
    @ApiOperation(value = "查询")
    public ResponseResult findByNameAndPage(ChannelDto dto) {
//        int a=1/0;
        return adChannelService.findByNameAndPage(dto);
    }

    @Override
    @PostMapping("/save")
    @ApiOperation(value = "添加")
    public ResponseResult insert(@RequestBody AdChannel channel) {
        return adChannelService.insert(channel);
    }

    @Override
    @PostMapping("/update")
    @ApiOperation(value = "修改")
    public ResponseResult update(@RequestBody AdChannel channel) {
        return adChannelService.update(channel);
    }

    @Override
    @GetMapping("delete/{id}")
    @ApiOperation(value = "删除")
    public ResponseResult deleteById(@PathVariable("id") Integer id) {
        return adChannelService.deleteById(id);
    }

}
